package com.qdu.study_app.Receiver;

import android.app.Notification;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import androidx.core.app.NotificationCompat;

import com.qdu.study_app.Activity.Activity_clock;
import com.qdu.study_app.MainActivity;
import com.qdu.study_app.service.ClockService;
import com.qdu.study_app.utils.MyToast;

public class TimeCountReceiver extends BroadcastReceiver {
    private View v;
    public TimeCountReceiver(View v) {
        this.v = v;
    }

    public TimeCountReceiver() {
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        switch (intent.getAction()){
            case ClockService.ACTION_TIME_TICK:
                //MyToast.showToast(context,"广播", Toast.LENGTH_SHORT);
                ((TextView)v).setText(intent.getStringExtra(ClockService.TEXT_TIME));
                break;

            case ClockService.ACTION_TASK_TOBACK:
                // 配置通知消息
                /*NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
                NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context)
                        .setContentTitle("计时")
                        .setContentText("任务正在计时...")
                        .setAutoCancel(true);
                manager.notify(1,notificationBuilder.build());*/
        }
    }
}
